module.exports = confirmServe;

function confirmServe($uibModal) {
    function ModalInstanceCtrl($scope, $uibModalInstance) {
        $scope.ok = function() {
            $uibModalInstance.close();
        };

        $scope.cancel = function() {
            $uibModalInstance.dismiss();
        };
    };
    var self = this;
    return {
        warn: function() {
            self.title = "警告";
            return this;
        },
        tips: function() {
            self.title = "提示";
            return this;
        },
        show: function(msg) {
            self.title = self.title || "确认";
            self.message = msg || "是否确定此操作？";
            var modalHtml = '<div class="modal-header">' + self.title + '</div><div class="modal-body">' + self.message + '</div>';
            modalHtml += '<div class="modal-footer"><button class="btn btn-primary" ng-click="ok()">确定</button><button class="btn btn-warning" ng-click="cancel()">取消</button></div>';
            return $uibModal.open({
                template: modalHtml,
                size: 'sm',
                controller: ModalInstanceCtrl
            }).result;
        }
    }
}
